package cn.xlbweb.sso.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: bobi
 * @date: 2019-04-06 11:09
 * @description:
 */
public class DateUtil {

    private static final String FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Long dateToLong() {
        return System.currentTimeMillis();
    }

    public static Date longToDate(long time) {
        return new Date(time);
    }

    public static String longToDateFormat(long time) {
        SimpleDateFormat df = new SimpleDateFormat(FORMAT);
        return df.format(new Date(time));
    }

    public static String longToDateFormat(long time, String format) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.format(new Date(time));
    }

    public static String formatCurrentTime() {
        SimpleDateFormat df = new SimpleDateFormat(FORMAT);
        return df.format(new Date());
    }

    public static String formatCurrentTime(String format) {
        SimpleDateFormat df = new SimpleDateFormat(format);
        return df.format(new Date());
    }
}
